Add ASViewController#660
Conversation
|
This is more like a proof of concept. It's ok to not merge it :P |
bfcc3bb to
be0cc04
Compare
There was a problem hiding this comment.
Cool, I think this effectively does synchronous measurement here and means that just barely in time for -layout, there will be cached sizes.
What would happen if measureWithSizeRange were called on a background thread (on the node) and were still running at this point? Interestingly there haven't been other cases in usage (either framework or app) where I have needed to consider that.
Lastly, small nit, but always create a local variable for a structure that needs to be accessed twice. CGSize boundsSize = self.view.bounds.size;
There was a problem hiding this comment.
Yes, this is synchronous measurement. If it is instead asynchronous and still running at this point, the (backing) view will have the correct size (set previously) but look empty, because the node doesn't layout its subnodes. Once layout is done, we can call setNeedsLayout and subviews will appear correctly.
There was a problem hiding this comment.
Right — it's totally fine for this to be synchronous. Later, we can add the API to allow a user to trigger preparation of the view in advance, which would include layout. My question is - what if a user dispatch_async'd a call to measure:, and then pushed the view controller?
The answer may be that we get bad behavior. That's also not a big deal right now, as it would be unusual to manually call measure: in that way and then push the view — but it will be a key part of the final version of 2.0 to support kicking off asynchronous layout, and then having a call that is able to block on the remainder of it (e.g. "-ensureMeasurementComplete" or something — that is probably not a good name). It would return immediately if done, otherwise wait on the background operation.
There was a problem hiding this comment.
Sorry for misunderstood your question. That's indeed a tricky question. Yeah I think the behaviour would be undefined, at least for the current implementation. My main reason is that the async layout pass can finished right before or after any of these events: VC is pushed, loadView, viewWillLayoutSubviews, etc. If we block on the remainder in, say, viewDidAppear, we may be able to do final set up there in case the background operation missed these events.
(There is a high chance that I'm talking non-sense here, please take it with a grain of salt haha)
|
Nits picked. |
a289b5e to
571f257
Compare
… ASViewController.
…before its -fetchData method is called.
aa39053 to
f1391ed
Compare
…on't recognize them (yet).
f1391ed to
a864341
Compare
…ookarchive#660) * Make section mapping work even for empty sections * Unlock more cases and update changelog * Fix complexity documentation
I also update Multiplex sample to use the new ASViewController.